package com.example.util;

import android.text.TextUtils;

import java.util.regex.Pattern;

import static java.util.regex.Pattern.*;


/**
 * @author: NPF
 * @date: 2018/4/14.
 */
public class IntegerUtil {


    private static IntegerUtil mInstance;

    private IntegerUtil() {
    }

    public static IntegerUtil getInstance() {
        if (null == mInstance) {
            synchronized (IntegerUtil.class) {
                if (null == mInstance) {
                    mInstance = new IntegerUtil();
                }
            }
        }
        return mInstance;
    }


    /**
     * 判断是否为数字
     *
     * @param integerStr
     * @return
     */
    public boolean isInteger(String integerStr) {
        boolean isInteger = false;
        if (!TextUtils.isEmpty(integerStr)) {
            Pattern pattern = compile("^[-\\+]?[\\d]*$");
            isInteger = pattern.matcher(integerStr).matches();
        }
        return isInteger;
    }
}
